﻿using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Web.Configuration;
using MVCBootstrap.MongoDB.Web.Security;

namespace MVCBootstrap.Tests.MongoDB {

	public static class RoleTestHelper {

		public static NameValueCollection GetSettings(String name) {
			var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

			// Add the provider.            
			var roleManager = (RoleManagerSection)config.GetSection("system.web/roleManager");
			roleManager.DefaultProvider = name;

			var provider = new ProviderSettings(name, typeof(MongoDBRoleProvider).AssemblyQualifiedName);
			roleManager.Providers.Clear();
			roleManager.Providers.Add(provider);

			config.Save(ConfigurationSaveMode.Modified);
			ConfigurationManager.RefreshSection("system.web/roleManager");

			return new NameValueCollection {
            };
		}
	}
}